﻿using System;
using System.Reflection;
public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public Person(string name, int age)
    {
        Name = name;
        Age = age;
    }
    public override string ToString()
    {
        return $"Person:{Name},Age:{Age}";
    }
}
class Program
{
    static void Main()
    {
        Type personType = typeof(Person);
        ConstructorInfo constructor = personType.GetConstructor(new Type[] { typeof(string), typeof(int) });
        if (constructor != null)
        {
            object personInstance=constructor.Invoke(new object[]{ "ljs",19});
            Person person=personInstance as Person;
            if (person != null)
            {
                Console.WriteLine(person);    //隐形调用Tostring（）；
            }
        }
        else
        {
            Console.WriteLine("No suitable constructor found");
        }
    }

}